package com.my.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.my.admin.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * @author my
 */
public interface UserMapper extends BaseMapper<User> {

    /**
     * @param username
     * @return 角色名
     */
    @Select("select role.name from role, user, user_role where user.id = user_role.user_id and role.id = user_role.role_id and username=#{username}")
    Set<String> getRoleByUserName(@Param("username") String username);

    /**
     * @param username
     * @return 菜单编码
     */
    @Select("select menu.code from role, user, user_role, menu, role_menu where user.id = user_role.user_id and role.id = user_role.role_id and user_role.role_id=role_menu.role_id and role_menu.menu_id=menu.id and username=#{username}")
    Set<String> getMenuByUserName(@Param("username") String username);

}
